

<title>用户列表</title>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>选课</cite></a>
        <a><cite>用户列表</cite></a>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">用户列表</div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="test-table-page" lay-filter="test"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['jquery', 'table', 'element'], function(){
        var $ = layui.$, form = layui.form,
            table = layui.table, admin = layui.admin,
            view = layui.view;

        var classNum;
        var index = window.location.href.indexOf("=");
        if (index !== -1) {
            classNum = window.location.href.substr(index + 1);
            renderTable(classNum);
        }else {
            admin.popup({
                title: "选择课程",
                area: ["420px", "450px"],
                id: "LAY-popup-user-edit",
                success: function(layero, index) {
                    view(this.id).render("menu/elective/classuserform").done(function() {
                        form.on("submit(LAY-user-back-submit)", function(data) {
                            layer.close(index);
                            var field = data.field;
                            classNum = field.classNum;
                            if (classNum === "" || classNum === undefined || classNum === null) {
                                return;
                            }
                            renderTable(classNum);
                        })
                    })
                }
            });
        }

        function renderTable(classNum) {
            var load = layer.load(2);
            table.render({
                elem: '#test-table-page'
                ,url: "/uclass/admin/elective/classcoins?classNum=" + classNum
                ,method: 'get'
                ,cols: [[
                    {type: 'numbers', title: 'ID'}
                    ,{field:'usercode', title: '学号'}
                    ,{field: 'username', title:'姓名' }
                    ,{field: 'coin', title:'选课币'}
                ]]
                ,parseData: function(res) {
                    return {
                        "status": res.status,
                        "message": res.message,
                        "data": res.data
                    };
                }
                ,done: function () {
                    layer.close(load);
                }
                ,response: {
                    statusName: 'status'
                    ,statusCode: 200
                    ,msgName: 'message'
                    ,dataName: 'data'
                }
            });
        }

    });
</script>